// __MICRO_APP_ENVIRONMENT__和__MICRO_APP_PUBLIC_PATH__是由micro-app注入的全局变量
if (window.__MICRO_APP_ENVIRONMENT__) {
  // eslint-disable-next-line
  __webpack_public_path__ = window.__MICRO_APP_PUBLIC_PATH__
}


import Vue from 'vue'
import App from './App.vue'
import router from './router'
Vue.config.productionTip = false


let app
/** 挂载函数 */
function mount () {
    app = new Vue({
      router,
      render: h => h(App),
    }).$mount('#vueApp')
}

/** 卸载函数 */
function unmount () {
  app.$destroy()
  app.$el.innerHTML = ''
  app.$el.id = 'vueApp'
  app = null
}

// 微前端环境下，注册mount和unmount方法
if (window.__MICRO_APP_ENVIRONMENT__) {
  window[`micro-app-${window.__MICRO_APP_NAME__}`] = { mount, unmount }
} else {
  mount()
}
   
